import { PetSkillListPanel } from "./PetSkillListPanel";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { PetSkillItem } from "./PetSkillItem";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { SPetSkill } from "../../../../../Message/Game/SPetSkill";
import { SkillConfig } from "../../../resource/SkillConfig";
//class PetInfoSkillListPanel
    
    export  class PetInfoSkillListPanel extends PetSkillListPanel
    {
        constructor(arg1: Boolean=false)
        {
            super(arg1);
            return;
        }

        public /* override */ init(arg1: Boolean=false): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            loc3 = 0;
            while (loc3 < 12) 
            {
                loc2 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
                loc2.width = 38;
                loc2.height = 38;
                loc1 = new PetSkillItem();
                loc1.isDig = false;
                loc1.setSize(32, 32);
                loc1.y = 3;
                if (loc3 < 2) 
                {
                    loc2.x = loc3 % 2 * 40 + 119;
                    loc2.y = 0;
                    loc1.x = loc2.x + 3;
                    loc1.y = loc2.y + 3;
                }
                else 
                {
                    loc2.x = (loc3 - 2) % 5 * 40;
                    loc2.y = (Math.floor((loc3 - 2) / 5) + 1) * 42;
                    loc1.x = loc2.x + 3;
                    loc1.y = loc2.y + 3;
                }
                if (loc3 < 4) 
                {
                    loc1.type = 0;
                }
                else if (loc3 >= 4 && loc3 < 12) 
                {
                    loc1.type = 1;
                }
                loc1.index = loc3;
                _skillItemArray.push(loc1);
                this.addChild(loc2);
                this.addChild(loc1);
                loc1.addEventListener(flash.events.MouseEvent.CLICK, onSkillItemClickHandler);
                ++loc3;
            }
            return;
        }

        protected /* override */ updateByPetInfo(arg1: SPetInfo): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=null;
            var loc7=0;
            _petInfo = arg1;
            clearSkillList();
            var loc2=[];
            if (arg1) 
            {
                loc1 = arg1.maxSkillAmount;
                loc2 = arg1.skills;
                loc5 = 0;
                while (loc5 < loc2.length) 
                {
                    loc3 = loc2[loc5] as SPetSkill;
                    if (!SkillConfig.instance.isSpecialSkill(loc3.skillId)) 
                    {
                        (loc4 = _skillItemArray[(loc3.pos - 1)]).index = loc5;
                        setSkill(loc4, loc3);
                    }
                    ++loc5;
                }
                loc7 = 0;
                while (loc7 < _skillItemArray.length) 
                {
                    (loc6 = _skillItemArray[loc7]).petInfo = arg1;
                    if (loc7 < 12) 
                    {
                        if (loc7 < loc1) 
                        {
                            loc6.type = 0;
                        }
                        else 
                        {
                            loc6.type = 1;
                        }
                    }
                    else 
                    {
                        loc6.type = arg1.reinLevel > 0 ? 0 : 2;
                    }
                    ++loc7;
                }
            }
            return;
        }
    }
